<?php

	add_action( 'wp_enqueue_scripts', 'cv_wpsocialite_enqueue_scripts' );


		function cv_wpsocialite_enqueue_scripts()
		{
			global $cv_option;
	
			if(!is_admin() && $cv_option['sc_disable_socials'] != true){
			
				wp_enqueue_script('jquery');
			//	wp_enqueue_script('jquery-ui-tabs');
				wp_enqueue_script('cv-socialite-lib', trailingslashit( THEME_FUNCTIONS_URI ) . 'wpsocialite/lib/socialite.min.js', array('jquery'), '1.0', true);
				
				if($cv_option['sc_socials_mode'] == 'on-hover')
					$value = 'on-hover';
				else
					$value = 'scroll';
				if($value == 'scroll'){
					wp_enqueue_script('cv-wpsocialite-scroll', trailingslashit( THEME_FUNCTIONS_URI ) . 'wpsocialite/lib/wpsocialite-scroll.js', array('jquery'), '1.0', true);				
				}else{
					wp_enqueue_script('cv-wpsocialite-hover', trailingslashit( THEME_FUNCTIONS_URI ) . 'wpsocialite/lib/wpsocialite-hover.js', array('jquery'), '1.0', true);
				}
				
				wp_enqueue_style('cv-socialite-css', trailingslashit( THEME_FUNCTIONS_URI ) . 'wpsocialite/lib/socialite.css');
				
			}// if is admin
			
		} // wpsocialite_enqueue_scripts


		
		function cv_wpsocialite_markup($size = null, $limit = 4) 
		{
			global $cv_option;
			global $wp_query;
			$post = $wp_query->post; //get post content
			$id = $post->ID; //get post id
			$postlink = get_permalink($id); //get post link
			$title = trim($post->post_title); // get post title
           
			if($size == 'small'){				
				$return_social_small = '
				<ul id="socialite-small" class="social-buttons cf">';
					if($limit>=1)
						$return_social_small .= '<li><a href="http://twitter.com/share" class="socialite twitter" data-text="' . $title . '" data-url="'.$postlink.'" data-count="horizontal" data-via="' . basename($cv_option['sm_twitter_url']) . '" rel="nofollow" target="_blank"><span>Share on Twitter</span></a></li>';
					if($limit>=2)
						$return_social_small .= '<li><a href="http://www.facebook.com/sharer.php?u='.$postlink.'" class="socialite facebook" data-href="'.$postlink.'" data-send="false" data-layout="button_count" data-width="60" data-show-faces="false" rel="nofollow" target="_blank"><span>Share on Facebook</span></a></li>';
					if($limit>=3)
						$return_social_small .= '<li><a href="https://plus.google.com/share?url='.$postlink.'" class="socialite googleplus" data-size="medium" data-href="'.$postlink.'" rel="nofollow" target="_blank"><span>Share on Google+</span></a></li>';
					if($limit>=4)
						$return_social_small .= '<li><a href="http://www.linkedin.com/shareArticle?mini=true&amp;url='.$postlink.'" class="socialite linkedin" data-url="'.$postlink.'" data-counter="right" rel="nofollow" target="_blank"><span>Share on LinkedIn</span></a></li>';
				$return_social_small .= '</ul>';
				
				return $return_social_small;
			} else {			
				$return_social_large = '
				<ul id="socialite-large" class="social-buttons cf">';
					if($limit>=1)
						$return_social_large += '<li><a href="http://twitter.com/share" class="socialite twitter" data-text="Socialite.js" data-url="'.$postlink.'" data-count="vertical" data-via="colorvila" rel="nofollow" target="_blank"><span>Share on Twitter</span></a></li>';
					if($limit>=2)
						$return_social_large += '<li><a href="http://www.facebook.com/sharer.php?u='.$postlink.'" class="socialite facebook" data-href="'.$postlink.'" data-send="false" data-layout="box_count" data-width="60" data-show-faces="false" rel="nofollow" target="_blank"><span>Share on Facebook</span></a></li>';
					if($limit>=3)
						$return_social_large += '<li><a href="https://plus.google.com/share?url='.$postlink.'" class="socialite googleplus" data-size="tall" data-href="'.$postlink.'" rel="nofollow" target="_blank"><span>Share on Google+</span></a></li>';
					if($limit>=4)
						$return_social_large += '<li><a href="http://www.linkedin.com/shareArticle?mini=true&amp;url='.$postlink.'" class="socialite linkedin" data-url="'.$postlink.'" data-counter="top" rel="nofollow" target="_blank"><span>Share on LinkedIn</span></a></li>';
				$return_social_large += '</ul>';
				
				return $return_social_large;
			}

		} 

